const express = require("express");
const app = express();
app.use(express.static('public'));
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
    extended: true
}));
var goodsData = require("./datas/goods_data")
console.log(goodsData)
const {
    data
} = require("jquery");
const {
    json
} = require("express");

app.post('/register', (req, res) => {
    user_info = req.body;
    console.log(user_info)
    res.end("已接收")
})


app.post('/login', (req, res) => {
    user_update_info = req.body;
    console.log(user_update_info)
    if (user_info.name == user_update_info.name && user_info.password == user_update_info.password) {
        res.end("登陆成功，等待跳转")
    } else {
        res.end("登陆失败，请重新注册")
    }

})


// app.post('/register', (req, res) => {
//     console.log(req.body);
//     
// })


app.get("/goods", (req, res) => {
    res.json(goodsData)
})

app.listen(8080, (err) => {
    if (!err) {
        console.log("SUCEED")
    } else {
        console.log("FLIED")
    }
})